package com.koron.common.web.controller.message;

import com.github.pagehelper.PageInfo;
import com.koron.bean.base.Response;
import com.koron.bean.query.PageQuery;
import com.koron.common.core.business.message.bean.po.MessageTemplatePo;
import com.koron.common.core.business.message.service.MessageTemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 消息模板表(MessageTemplate)表控制层
 *
 * @author zhouj
 * @since 2022-03-16 14:13:47
 */
@Api(tags = "消息模板表(MessageTemplate)")
@RestController
@RequestMapping("/messageTemplate/")
public class MessageTemplateController {

    @Autowired
    private MessageTemplateService messageTemplateService;

    @ApiOperation(value = "新增或修改消息模板表")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody MessageTemplatePo messageTemplate) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "insertOrUpdate", Integer.class, messageTemplate));
    }

    @ApiOperation(value = "新增消息模板表")
    @PostMapping("insert")
    public Response<Integer> insert(@RequestBody MessageTemplatePo messageTemplate) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "insert", Integer.class, messageTemplate));
    }

    @ApiOperation(value = "批量新增消息模板表")
    @PostMapping("insertBatch")
    public Response<Integer> insertBatch(@RequestBody List<MessageTemplatePo> messageTemplateList) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "insertBatch", Integer.class, messageTemplateList));
    }

    @ApiOperation(value = "根据id更新消息模板表")
    @PutMapping("update")
    public Response<Integer> update(@RequestBody MessageTemplatePo messageTemplate) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "update", Integer.class, messageTemplate));
    }

    @ApiOperation(value = "根据id删除消息模板表")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据id查询消息模板表")
    @GetMapping("queryById")
    public Response<MessageTemplatePo> queryById(String id) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "queryById", MessageTemplatePo.class, id));
    }

    @ApiOperation(value = "不分页查询消息模板表列表")
    @GetMapping("queryList")
    public Response<List> queryList(MessageTemplatePo queryVo) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "queryList", List.class, queryVo));
    }

    @ApiOperation(value = "分页查询消息模板表列表")
    @GetMapping("queryPageList")
    public Response<PageInfo> queryPageList(MessageTemplatePo queryPo, PageQuery pageQuery) {
        return Response.ok(ADOConnection.runTask(messageTemplateService, "queryPageList", PageInfo.class, queryPo, pageQuery));
    }

}
